<template>
  <div class="home-container">
    <div class="main-section">
      <!-- 左侧 欢迎内容 -->
      <div class="hero-content">
        <h1 class="hero-title">欢迎来到 <span class="brand-name">学了吗</span></h1>
        <p class="hero-subtitle">您的英语在线学习平台</p>

        <div class="hero-actions">
          <template v-if="!userStore.isLoggedIn">
            <router-link to="/login" class="btn btn-primary">立即登录</router-link>
            <router-link to="/register" class="btn btn-secondary">免费注册</router-link>
          </template>
          <template v-else>
            <div class="welcome-message">
              <h2>欢迎回来，{{ userStore.userInfo.username }}！</h2>
              <div class="start-learning-btn" @click="goToHome">
                <span class="btn-text">开始您的学习之旅</span>
                <span class="btn-arrow">gogogo </span>
              </div>
            </div>
          </template>
        </div>
      </div>

      <!-- 右侧 平台特色 -->
      <div class="features-section">
        <h2 class="section-title">平台特色</h2>
        <div class="features-grid">
          <div class="feature-card">
            <div class="feature-icon">📚</div>
            <h3>丰富课程</h3>
            <p>涵盖多个领域的优质课程内容</p>
          </div>
          <div class="feature-card">
            <div class="feature-icon">🎯</div>
            <h3>个性化学习</h3>
            <p>根据您的学习进度推荐合适内容</p>
          </div>
          <div class="feature-card">
            <div class="feature-icon">👥</div>
            <h3>社区互动</h3>
            <p>与其他学习者交流分享经验</p>
          </div>
          <div class="feature-card">
            <div class="feature-icon">📊</div>
            <h3>学习统计</h3>
            <p>详细的学习进度和成绩分析</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useUserStore } from '@/stores/userStore.js'
import { useRouter } from 'vue-router'

const userStore = useUserStore()
const router = useRouter()

const goToHome = () => {
  router.push('/')
}
</script>

<style scoped>
.home-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  overflow: hidden;
  background: white;
}

.main-section {
  display: flex;
  width: 100%;
  height: 100%;
  margin: 0 50px 0;
}

/* 左边：欢迎区域 */
.hero-content {
  flex: 0.5;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 5rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;

}

.hero-title {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.brand-name {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
  text-shadow: 0 0 30px rgba(251, 191, 36, 0.5);
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.5));
  }
  to {
    filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.8));
  }
}

.hero-subtitle {
  font-size: 1.5rem;
  opacity: 0.9;
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  padding: 1rem 2rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  display: inline-block;
}

.btn-primary {
  background: white;
  color: #667eea;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
}

.btn-secondary:hover {
  background: white;
  color: #667eea;
  transform: translateY(-2px);
}

/* 欢迎消息区域 */
.welcome-message {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.welcome-message h2 {
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
  opacity: 0.95;
}

.start-learning-btn {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.4rem;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.3);
  user-select: none;
  max-width: fit-content;
}

.start-learning-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(251, 191, 36, 0.5);
  background: linear-gradient(135deg, #fcd34d 0%, #fbbf24 100%);
}

.start-learning-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.btn-text {
  letter-spacing: 0.5px;
}

.btn-arrow {
  font-size: 1.5rem;
  transition: transform 0.3s ease;
}

.start-learning-btn:hover .btn-arrow {
  transform: translateX(5px);
}

/* 右边：平台特色 */
.features-section {
  flex: 0.5;
  background: #f7fafc;
  padding: 5rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.section-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 3rem;
  text-align: left;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 两列 */
  gap: 2rem;
}

.feature-card {
  background: white;
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 1rem;
}

.feature-card p {
  color: #718096;
  line-height: 1.6;
}

/* 响应式布局 */
@media (max-width: 900px) {
  .main-section {
    flex-direction: column;
  }

  .hero-content, .features-section {
    flex: none;
    width: 100%;
    height: auto;
    text-align: center;
  }

  .section-title {
    text-align: center;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }
}
</style>
